// bool, Obj This, Obj other

Hero this;
Building bld;
Settlement sett;
Wagon wagon;
str cmmd;

this = This.AsHero();
if(!.IsValid()) return false;
cmmd = .command;
bld = other.AsBuilding();
if(bld.IsValid()){
	if(!.IsEnemy(bld)) return false;
	if(!.IsValidCaptureTarget(bld)) return false;
	sett = bld.settlement;
	if(sett.IsOutpost())
		if(sett.IsIndependent())
			return false;
	
	if(.HasItem("irage_battle")) return false;
	if(.HasItem("irage_battle_stand")) return false;
	if(cmmd == "retreat_notai") return false;
	if(cmmd == "retreat_bld_notai") return false;
	if(cmmd == "great_charge") return false;
} else {

	wagon = other.AsWagon();
	if(!wagon.IsValid()) return false;
	if(!.IsEnemy(wagon)) return false;
	
	if(.HasArmy){
		if(.HasItem("irage_battle")) return false;
		if(.HasItem("irage_battle_stand")) return false;
		if(cmmd == "retreat_notai") return false;
		if(cmmd == "retreat_bld_notai") return false;
		if(cmmd == "great_charge") return false;
	}
}
return true;
